package com.leaf.lowcode.controller;


import com.alibaba.fastjson.JSONObject;
import com.leaf.lowcode.domain.JsonData;
import com.leaf.lowcode.entity.SearchesRequest;
import com.leaf.lowcode.sdk.ArtemisPostTest_a;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sik")
@PropertySource({"classpath:resource.properties"})
public class AController {

    @PostMapping(value="getSearches")
    @ResponseBody
    public JsonData getSearches(@RequestBody JSONObject jsonObject){
        Object pageNo = jsonObject.get("pageNo");
        Object pageSize = jsonObject.get("pageSize");
        if (null == pageNo || null == pageSize) {
            return new JsonData(-1, "缺少参数pageNo\\pageSize，请填写正确参数");
        }else{
            SearchesRequest searchesRequest = new SearchesRequest();
            searchesRequest.setPageNo(Integer.parseInt(pageNo.toString()));
            searchesRequest.setPageSize(Integer.parseInt(pageSize.toString()));
            String searches = ArtemisPostTest_a.searches(searchesRequest);
            return new JsonData(1, searches);
        }
    }

}
